Socket
Socket
Sign inDemoInstall

update-input-width

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

update-input-width

A function that given input element, updates its width to fit its content.


Version published
Weekly downloads
260K
increased by3.27%
Maintainers
1
Weekly downloads
 
Created
Source

npm downloads CI

Update-Input-Width

A function that given an input element, updates its width to fit its content.

tl;dr

  • Install by executing npm install update-input-width or yarn add update-input-width.
  • Import by adding import updateInputWidth from 'update-input-width'.
  • Use it by calling it with input element as an argument.

User guide

updateInputWidth(element: HTMLInputElement)

A function that given an input element, updates its width to fit its content by setting inline width CSS property.

Sample usage
import updateInputWidth from 'update-input-width';

updateInputWidth(myInput); // 42

or

import { updateInputWidth } from 'update-input-width';

updateInputWidth(myInput); // 42

getFontShorthand(element: HTMLElement)

A function that given HTML element returns font CSS shorthand property. Equal to Chrome-only code:

window.getComputedStyle(element).font;
Sample usage
import { getFontShorthand } from 'update-input-width';

getFontShorthand(myInput); // 'normal normal 600 normal 20px / 25px Arial, sans-serif'

measureText(text: string, font: string)

A function that given text and font CSS shorthand property returns text width in pixels.

Sample usage
import { measureText } from 'update-input-width';

measureText('hello', 'normal normal 600 normal 20px / 25px Arial, sans-serif'); // 42

License

The MIT License.

Author

Wojciech Maj Wojciech Maj

Keywords

FAQs

Package last updated on 18 Oct 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc